package com.syedu.day08.homework;

import java.time.LocalDate;

/**
 * @Description 小时工
 * @createTime 2022/3/17 17:07
 * @author Administrator
 */
public class HourlyEmployee extends Employee {
    //每小时的工资
    private double payEachHour;
    // 每月工作的小时数
    private int hours;

    public HourlyEmployee() {

    }

    public HourlyEmployee(String name, LocalDate birthday, double payEachHour, int hours) {
        super(name, birthday);
        this.payEachHour = payEachHour;
        this.hours = hours;
    }

    public double getPayEachHour() {
        return payEachHour;
    }

    public void setPayEachHour(double payEachHour) {
        this.payEachHour = payEachHour;
    }

    public int getHours() {
        return hours;
    }

    public void setHours(int hours) {
        this.hours = hours;
    }

    @Override
    public double getSalary(int month) {
        //每月工作超出160小时的部分按照1.5倍工资发放
        double money = super.getSalary(month) + payEachHour * hours;
        //判断工作小时数
        if (hours > 160) {
            money += (hours - 160) * payEachHour * 0.5;
        }
        return money;
    }
}
